package net.pimpas.web.jsf.components.tree;

import javax.faces.component.UIComponent;

import net.pimpas.web.jsf.components.UIComponentPimpasBaseTag;

public class UITreeTag extends UIComponentPimpasBaseTag {
	
	private String componentPath;
	private String title;
	private String onNodeRemoved;
	private String onNodeAdded;
	private String onNodeChanged;
	private String onChange;
	
	@Override
	protected void setProperties(UIComponent component) {
		UITree tree = (UITree) component;
		
		if(this.getComponentPath() == null || "".equals(this.getComponentPath()))
			this.setComponentPath(UITree.DEFAULT_COMPONENT_PATH);
		if(this.getTitle() == null)
			this.setTitle("none");
		
		tree.setComponentPath(this.getComponentPath());
		tree.setTitle(this.getTitle());
		tree.setOnNodeRemoved(this.getOnNodeRemoved());
		tree.setOnNodeAdded(this.getOnNodeAdded());
		tree.setOnNodeChanged(this.getOnNodeChanged());
		tree.setOnChange(this.getOnChange());
		
		super.setProperties(component);
	}

	@Override
	public String getComponentType() {
		return UITree.COMPONENT_TYPE;
	}

	public String getComponentPath() {
		return componentPath;
	}

	public void setComponentPath(String componentPath) {
		this.componentPath = componentPath;
	}

	public String getOnNodeAdded() {
		return onNodeAdded;
	}

	public void setOnNodeAdded(String onNodeAdded) {
		this.onNodeAdded = onNodeAdded;
	}

	public String getOnNodeChanged() {
		return onNodeChanged;
	}

	public void setOnNodeChanged(String onNodeChanged) {
		this.onNodeChanged = onNodeChanged;
	}

	public String getOnNodeRemoved() {
		return onNodeRemoved;
	}

	public void setOnNodeRemoved(String onNodeRemoved) {
		this.onNodeRemoved = onNodeRemoved;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getOnChange() {
		return onChange;
	}

	public void setOnChange(String onChange) {
		this.onChange = onChange;
	}
}